package com.ai.ly.goodsautocat.util;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class FileUtil {

    /**
     * 获取工程中的文件（相对路径）
     * @param path
     * @return
     * @author liangyi
     */
    public static File getFileInSys(String path) {
        String filePath=path;
        try {
            ClassLoader classLoader = ClassLoader.getSystemClassLoader();
            filePath= classLoader.getResource(filePath).getPath();
            filePath=URLDecoder.decode(filePath,"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        }
          
        File file=new File(filePath);
        return file;
    }
    
}
